package view.inventory.menu
{
import core.Language;
import core.manager.BonusManager;
import core.model.GameModel;

import framework.view.components.button.ButtonProxy;

import values.item.PackItemValue;

/**
 * InventoryPackItemMenuProxy
 * @author jliang
 *
 */
public class InventoryPackItemMenuProxy extends InventoryItemMenuProxy
{
    //==========================================================================
    //  Constructor
    //==========================================================================
    public function InventoryPackItemMenuProxy()
    {
        super();
    }
    //==========================================================================
    //  Overridden methods: ComponentProxy
    //==========================================================================	
    override protected function get proxyMapping():Array
    {
        return [ 
            { skin:"useBtn", classRef: ButtonProxy, id:"useBtn", text:Language.getText("@open_pack_button_label"), onClick: useHandler }
        ].concat(super.proxyMapping);
    }	
    //==========================================================================
    //  Event handlers
    //==========================================================================
    protected function useHandler():void
    {
        var pack:PackItemValue = data as PackItemValue;
        if (BonusManager.hasEoughSpaceToAddItemBonus(pack.items))
        {
            GameModel.instance.playerModel.openPack(pack.packTemplate);
        }
        else
        {
            trace("背包已经没有足够的空间了.");
        }
    }
}
}




